From 8383ddfff59a21989863a40351a93c1b6ce4218b Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 22 Jan 2009 11:11:39 +0000 Subject: [PATCH] x86 ucode: optimizing microcode update It's possible the data file has multiple matching ucode, we needn't to update multiple times, just keep searching the latest version, and update once. Signed-off-by: Liu, Jinsong --- xen/arch/x86/microcode_intel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/microcode_intel.c b/xen/arch/x86/microcode_intel.c index 8681a6945f..c93df509ad 100644 --- a/xen/arch/x86/microcode_intel.c +++ b/xen/arch/x86/microcode_intel.c @@ -325,6 +325,7 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t size) long offset = 0; int error = 0; void *mc; + unsigned int matching_count = 0; /* We should bind the task to the CPU */ BUG_ON(cpu != raw_smp_processor_id()); @@ -343,7 +344,7 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t size) */ if ( error == 1 ) { - apply_microcode(cpu); + matching_count++; error = 0; } xfree(mc); @@ -353,6 +354,9 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t size) if ( offset < 0 ) error = offset; + if ( !error && matching_count ) + apply_microcode(cpu); + return error; } -- 2.30.2